{include file="public/_meta" /}
<link href="/static/admin/lib/webuploader/0.1.5/webuploader.css" rel="stylesheet" type="text/css" />
</head>
<style>

    .lbwxq_mImg {
        width: 110px;
        height: 110px;
        border: 1px solid #eee;
        position: relative;
    }

    .lbwxq_mImg img {
        width: 110px;
        height: 110px;
    }


    .big img{
        width: 1000px;
        height: 1000px;
    }

    /*大图*/

    .lbwxq_lImg {
        width: 500px;
        height: 500px;
        position: absolute;
        left: 540px;
        top: 25px;
        display: none;
        overflow: hidden;
    }

    .lbwxq_lImg img {
        width: 1000px;
        height: 1000px;
    }


    .pic {
        display: inline-block;
    }

    .pic img {
        width: 110px;
        height: 110px;
    }
    body,html{
    position: relative;
    }
    .big{
       position: absolute;
        right: 25%;
        top: 120px;
        width: 300px;
        height: 300px;
    }
    .big img{
        width: 100%;
        height: 100%;
    }
</style>

<body>
    <nav class="breadcrumb"><i class="Hui-iconfont">&#xe67f;</i> 首页 <span class="c-gray en">&gt;</span>商品管理 <span class="c-gray en">&gt;</span> 修改商品 <a class="btn btn-success radius r" style="line-height:1.6em;margin-top:3px" href="javascript:location.replace(location.href);" title="刷新"><i class="Hui-iconfont">&#xe68f;</i></a></nav>
    <div class="page-container">
        <form class="form form-horizontal" id="form-article-add">
            <input type="hidden" name="__token__" value="{$Request.token}" />


            <div class="row cl">
                <label class="form-label col-xs-4 col-sm-2"><span class="c-red">*</span>商品名称：</label>
                <div class="formControls col-xs-8 col-sm-9">
                    <input type="text" class="input-text" placeholder="商品名称" name="pd_name" value="{$info.pd_name}" style="width:20%">
                </div>
            </div>



            <div class="row cl">
                <label class="form-label col-xs-4 col-sm-2"><span class="c-red">*</span>供应商：</label>
                <div class="formControls col-xs-8 col-sm-9">
                    <span class="select-box" style="width:20%">
                        <select name="gong_id"  class="select">
                            <option value="">选择供应商</option>
                            {volist name="ghInfo" id="vo"}
                                <option value="{$vo.id}" {if condition = "$vo.id eq $info.gong_id"} selected="selected" {/if}>┣{$vo.ad_tel}  {$vo.ad_name}</option>
                            {/volist}
                        </select>
                    </span>
                </div>
            </div>



            <div class="row cl">
                <label class="form-label col-xs-4 col-sm-2"><span class="c-red">*</span>商品分类：</label>
                <div class="formControls col-xs-8 col-sm-9">
                    <span class="select-box" style="width:20%">
                        <select name="ca_id"  class="select">
                            <option value="">请选择分类</option>
                             <option value="1" {if condition = "1 eq $info.ca_id"} selected="selected" {/if}>会员和店主区</option>
                            <option value="2" {if condition = "2 eq $info.ca_id"} selected="selected" {/if}>店主区</option>
                        </select>
                    </span>
                </div>
            </div>




            <div class="row cl">
                <label class="form-label col-xs-4 col-sm-2"><span class="c-red">*</span>商品价格：</label>
                <div class="formControls col-xs-8 col-sm-9">
                    <input type="text" class="input-text" placeholder="商品价格" name="pd_price" value="{$info.pd_price}" style="width:20%">
                </div>
            </div>


            <div class="row cl">
                <label class="form-label col-xs-4 col-sm-2"><span class="c-red">*</span>供应商分配金额：</label>
                <div class="formControls col-xs-8 col-sm-9">
                    <input type="text" class="input-text" placeholder="供应商分配金额" name="gong_money" value="{$info.gong_money}" style="width:20%">
                </div>
            </div>




            <h5 style="color: red ;width: 48% ;text-align: center" >套餐内容请以 + 分开</h5>
            <div class="row cl">
                <label class="form-label col-xs-4 col-sm-2">套餐详情：</label>

                <div class="formControls col-xs-8 col-sm-9">
                    <textarea type="text"  placeholder="套餐内容请以 + 分开" name="pd_content" value="" style="width:20%" rows="3" cols="18">{$info.pd_content}</textarea>
                </div>
            </div>


            <div class="row cl">
                <label class="form-label col-xs-4 col-sm-2">商品缩略图：</label>
                <div class="formControls col-xs-8 col-sm-9">
                    <div style="width:110px;height: 110px;position: relative;display: inline-block; ">   
                        {if condition="$info.pd_head_pic"}
                            <img src="{$info.pd_head_pic}" class="logo" style="position: absolute;left: 0;top: 0;width: 100%;height: 100%;">
                        {else}
                            <img src="/static/admin/img/add0.png" class="logo" style="position: absolute;left: 0;top: 0;width: 100%;height: 100%;">
                        {/if}                     
                                               
                        <input type="file" name="file" onchange="eee($(this))" class="input-text" style="position: absolute;left: 0;top: 0;width: 100%;height: 100%;opacity: 0;">
                    </div>
                </div>
            </div>
            <div style="display:none" >
                <input type="text" name="pd_head_pic" value="{$info.pd_head_pic}">
                <input type="text" name="id" value="{$info.id}">
            </div>

            <div class="row cl">
                <label class="form-label col-xs-4 col-sm-2">商品主图：</label>
                <div class="formControls col-xs-8 col-sm-9">
                    <div class="pic" >
                        {volist name="$info.pd_pic" id="vo"}
                          <li class="maomao" style="position: relative; list-style: none;float: left">
                            <i class="Hui-iconfont ioc_x" onclick="remove_li(this)"  style="position: absolute;right: 0; top: 0;">&#xe6e2;</i>
                            <img  src="{$vo}" onclick="ccc(this)"  alt="">
                          </li>
                        {/volist}
                    </div>
                    <div style="width:110px;height: 110px;position: relative;display: inline-block; ">
                        <img src="/static/admin/img/add0.png" alt="" style="position: absolute;left: 0;top: 0;width: 100%;height: 100%;">
                        <input type="file" name="file" onchange="bbb($(this))" class="input-text" style="position: absolute;left: 0;top: 0;width: 100%;height: 100%;opacity: 0;">
                    </div>
                </div>
            </div>
            <div style="display:none" class="ttt">
                {volist name="$info.pd_pic" id="vo"}
                <input type="text" name="pd_pic[]" class="ppp" value="{$vo}">
                {/volist}
                <input type="text" name="pd_id" value="{$info.id}">
            </div>

            <div class="row cl">
                <label class="form-label col-xs-4 col-sm-2">内容：</label>
                <div class="formControls col-xs-8 col-sm-9">
            <textarea id="editor" type="text/plain" style="width:100%;height:400px;" name="content" >{$info.content|raw}
            </textarea>
                </div>
            </div>


            <div class="row cl">
                <div class="col-xs-8 col-sm-9 col-xs-offset-4 col-sm-offset-2">
                    <button onclick="return edit();" class="btn btn-primary radius" type="submit"><i class="Hui-iconfont">&#xe632;</i> 确认提交</button>
                </div>
            </div>
        </form>
    </div>
    <div class="big" >
        <!-- <img src="/static/admin/img/add0.png" /> -->
    </div>
    {include file="public/_footer" /}
    <script type="text/javascript" src="/static/admin/lib/ueditor/1.4.3/ueditor.config.js"></script>
    <script type="text/javascript" src="/static/admin/lib/ueditor/1.4.3/ueditor.all.min.js"> </script>
    <script type="text/javascript" src="/static/admin/lib/ueditor/1.4.3/lang/zh-cn/zh-cn.js"></script>
    <script type="text/javascript" src="/static/admin/lib/My97DatePicker/4.8/WdatePicker.js"></script>
    <!--请在下方写此页面业务相关的脚本-->
    <script type="text/javascript">

        $('select[name="gong_id"]').val({$Request.get.gong_id});
        $('select[name="ca_id"]').val({$Request.get.ca_id});

        $(function() {
            $('.skin-minimal input').iCheck({
                checkboxClass: 'icheckbox-blue',
                radioClass: 'iradio-blue',
                increaseArea: '20%'
            });
            $("#tab-system").Huitab({
                index: 0
            });
            var ue = UE.getEditor('editor');
        });

    function edit() {
        $.post('{:url("edit")}', $('#form-article-add').serialize()).success(function(data) {
            layer.msg(data.msg);
            if (data.code) {
                setTimeout(function() {
                    location.href = '';
                }, 1000);
            }
        });
        return false;
    }
    function bbb(dada) {
        var data = new FormData();
        data.append('file', dada[0].files[0]);
        var index = layer.load(1, { shade: false }); //0代表加载的风格，支持0-2
        $.ajax({
            url: '{:url("upload")}',
            type: 'POST',
            data: data,
            cache: false,
            contentType: false,
            processData: false,
            success: function(data) {
                layer.msg(data.msg);
                if (data.code) {
                    var html1 = '<li class="maomao" style="position: relative; list-style: none;float: left"><i  onclick="remove_li(this)" class="Hui-iconfont ioc_x" style="position: absolute;right: 0; top: 0;">&#xe6e2;</i><img src="' + data.data + '"  onclick="ccc(this)" alt=""></li>';
                    var html2 = '<input name="pd_pic[]" class="ppp" hidden="hidden" value="'+data.data+'">';
                    $('.pic').append(html1);
                    $('.ttt').append(html2);
                }
                layer.close(index);
            },
            error: function() {
                layer.close(index);
                layer.msg('上传出错');
            }
        });
    }
    function ccc(data){
        var path = $(data).attr('src');
        var html = '<img src="' + path + '" onclick="ddd()" alt="">';
        $('.big').html(html);
        $('.big').show();
    }
    function ddd(){
        $('.big').hide();
    }
    ddd();
    //删除主图
    function remove_li(data){

        var index = $('.maomao i').index(data);
        $(data).parent().remove();
        // var path = $(data).next('img').attr('src');
        // var val = $('.ppp').eq(index).val();
        $('.ppp').eq(index).remove();
    }

    function eee(dada) {
        var data = new FormData();
        data.append('file', dada[0].files[0]);
        var index = layer.load(1, { shade: false }); //0代表加载的风格，支持0-2
        $.ajax({
            url: '{:url("upload")}',
            type: 'POST',
            data: data,
            cache: false,
            contentType: false,
            processData: false,
            success: function(data) {
                layer.msg(data.msg);
                if (data.code) {
                    $('.logo').attr('src',data.data);
                    $('input[name="pd_head_pic"]').val(data.data);
                }
                layer.close(index);
            },
            error: function() {
                layer.close(index);
                layer.msg('上传出错');
            }
        });
    }
    // 新增sku
    function addSku() {
        i++;
        var html = 
            '<div class="row cl sku_item">' +
                '<label class="form-label col-xs-4 col-sm-2">商品规格：</label>' +
                '<div class="formControls col-xs-8 col-sm-9">' +
                    '<div class="col-md-3">' +
                        '<div class="formControls col-xs-12 col-sm-12 col-md-9" style="padding: 0">' +
                            '<input type="text" name="sku_list['+i+'][sku_name]" id="" placeholder="商品规格" value="" class="input-text">' +
                        '</div>' +
                    '</div>' +
                    '<div class=" col-md-2">' +
                        '<label class="form-label col-xs-12 col-sm-12 col-md-3" style="text-align: left;padding: 0">价格</label>' +
                        '<div class="formControls col-xs-12 col-sm-12 col-md-9" style="padding: 0">' +
                            '<input type="number" name="sku_list['+i+'][realprice]" id="" placeholder="对应价格" value="0" class="input-text">' +
                        '</div>' +
                    '</div>' +
                    '<div class=" col-md-2">' +
                        '<label class="form-label col-xs-12 col-sm-12 col-md-3" style="text-align: left;padding: 0">原价</label>' +
                        '<div class="formControls col-xs-12 col-sm-12 col-md-9" style="padding: 0">' +
                            '<input type="number" name="sku_list['+i+'][oldprice]" id="" placeholder="" value="0" class="input-text">' +
                        '</div>' +
                    '</div>' +
                    '<div class=" col-md-2">' +
                        '<button class="btn btn-danger" onclick="return rmSku(this,i)">移除</button>' +
                    '</div>' +
                '</div>' +
            '</div>';
        $('#sku').append(html);
        return false;
    }

    // 移除sku
    function rmSku(obj, skuid = 0) {
        //alert(obj);
        if (skuid) {
            $.get("{:url('rmSku')}", {skuid:skuid}, function(data){
                console.log(data);
                layer.msg(data.msg);
                if (data.code) {
                    $(obj).parent().parent().parent().remove();
                }
            });
        }
        return false;
    }
    function selecttime(flag){
    if(flag==1){
        var endTime = $("#countTimeend").val();
        if(endTime != ""){
            WdatePicker({dateFmt:'yyyy-MM-dd HH:mm',maxDate:endTime})}else{
            WdatePicker({dateFmt:'yyyy-MM-dd HH:mm'})}
    }else{
        var startTime = $("#countTimestart").val();
        if(startTime != ""){
            WdatePicker({dateFmt:'yyyy-MM-dd HH:mm',minDate:startTime})}else{
            WdatePicker({dateFmt:'yyyy-MM-dd HH:mm'})}
    }
 }
    </script>
</body>

</html>